{% load static %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
    <title>LG商城-用户中心</title>
    <link href="{% static 'css/reset.css' %}" rel="stylesheet" type="text/css">
    <link href="{% static 'css/main.css' %}" rel="stylesheet" type="text/css">
    <script src="{% static 'js/vue-2.5.16.js' %}" type="text/javascript"></script>
    <script src="{% static 'js/axios-0.18.0.min.js' %}" type="text/javascript"></script>
</head>
<body>
<div id="app">
    <div class="header_con">
        <div class="header" v-cloak>
            <div class="welcome fl">欢迎来到LG商城!</div>
            <div class="fr">
                <div class="login_btn fl" v-if="username">
                    欢迎您：<em>[[ username ]]</em>
                    <span>|</span>
                    <a href="{% url 'users:logout' %}">退出</a>
                </div>
                <div class="login_btn fl" v-else>
                    <a href="{% url 'users:login' %}">登录</a>
                    <span>|</span>
                    <a href="{% url 'users:register' %}">注册</a>
                </div>
                <div class="user_link fl">
                    <span>|</span>
                    <a href="{% url 'users:userInfo' %}">用户中心</a>
                    <span>|</span>
                    <a href="cart.html">我的购物车</a>
                    <span>|</span>
                    <a href="user_center_order.html">我的订单</a>
                </div>
            </div>
        </div>
    </div>
    <div class="search_bar clearfix">
        <a class="logo fl" href="{% url 'contents:index' %}"><img src="{% static 'images/1.png' %}"></a>
        <div class="search_wrap fl">
            <form action="/search/" class="search_con" method="get">
                <input class="input_text fl" name="q" placeholder="搜索商品" type="text">
                <input class="input_btn fr" name="" type="submit" value="搜索">
            </form>
            <ul class="search_suggest fl">
                <li><a href="#">索尼微单</a></li>
                <li><a href="#">优惠15元</a></li>
                <li><a href="#">美妆个护</a></li>
                <li><a href="#">买2免1</a></li>
            </ul>
        </div>
    </div>
    <div class="main_con clearfix">
        <div class="left_menu_con clearfix">
            <h3>用户中心</h3>
            <ul>
                <li><a href="{% url 'users:userInfo' %}">· 个人信息</a></li>
                <li><a class="active" href="{% url 'users:address' %}">· 收货地址</a></li>
                <li><a href="user_center_order.html">· 全部订单</a></li>
                <li><a href="user_center_pass.html">· 修改密码</a></li>
            </ul>
        </div>
        <div class="right_content clearfix" v-cloak>
            <div class="site_top_con">
                <a @click="show_add_site">新增收货地址</a>
                <span>你已创建了<b>[[ addresses.length ]]</b>个收货地址，最多可创建<b>20</b>个</span>
            </div>
            <div class="site_con" v-for="(address, index) in addresses">
                <div class="site_title">
                    <h3>[[ address.title ]]</h3>
                    <a class="edit_icon" @click="show_edit_title(index)"></a>
                    <em v-if="address.id===default_address_id">默认地址</em>
                    <span class="del_site" @click="delete_address(index)">×</span>
                </div>
                <ul class="site_list">
                    <li><span>收货人：</span><b>[[ address.receiver ]]</b></li>
                    <li><span>所在地区：</span><b>[[ address.province ]] [[address.city]] [[ address.district ]]</b></li>
                    <li><span>地址：</span><b>[[ address.place ]]</b></li>
                    <li><span>手机：</span><b>[[ address.mobile ]]</b></li>
                    <li><span>固定电话：</span><b>[[ address.tel ]]</b></li>
                    <li><span>电子邮箱：</span><b>[[ address.email ]]</b></li>
                </ul>
                <div class="down_btn">
                    <a v-if="address.id!=default_address_id" @click="set_default(index)">设为默认</a>
                    <a class="edit_icon" @click="show_edit_site(index)">编辑</a>
                </div>
            </div>
        </div>
    </div>
    <div class="footer">
        <div class="foot_link">
            <a href="#">关于我们</a>
            <span>|</span>
            <a href="#">联系我们</a>
            <span>|</span>
            <a href="#">招聘人才</a>
            <span>|</span>
            <a href="#">友情链接</a>
        </div>
        <p>CopyRight © 2016 长沙LG商业股份有限公司 All Rights Reserved</p>
        <p>电话：010-****888 京ICP备*******8号</p>
    </div>
    <div class="pop_con" v-cloak v-show="is_show_edit">
        <div class="site_con site_pop">
            <div class="site_pop_title">
                <h3 v-if="editing_address_index">编辑收货地址</h3>
                <h3 v-else>新增收货地址</h3>
                <a @click="is_show_edit=false">×</a>
            </div>
            <form>
                <div class="form_group">
                    <label>*收货人：</label>
                    <input @blur="check_receiver" class="receiver" type="text" v-model="form_address.receiver">
                    <span class="receiver_error" v-show="error_receiver">请填写收件人</span>
                </div>
                <div class="form_group">
                    <label>*所在地区：</label>
                    <select v-model="form_address.province_id">
                        <option :value="province.id" v-for="province in provinces">[[ province.name ]]</option>
                    </select>
                    <select v-model="form_address.city_id">
                        <option :value="city.id" v-for="city in cities">[[ city.name ]]</option>
                    </select>
                    <select v-model="form_address.district_id">
                        <option :value="district.id" v-for="district in districts">[[ district.name ]]</option>
                    </select>
                </div>
                <div class="form_group">
                    <label>*详细地址：</label>
                    <input @blur="check_place" class="place" type="text" v-model="form_address.place">
                    <span class="place_error" v-show="error_place">请填写地址信息</span>
                </div>
                <div class="form_group">
                    <label>*手机：</label>
                    <input @blur="check_mobile" class="mobile" type="text" v-model="form_address.mobile">
                    <span class="mobile_error" v-show="error_mobile">手机信息有误</span>
                </div>
                <div class="form_group">
                    <label>固定电话：</label>
                    <input @blur="check_tel" class="tel" type="text" v-model="form_address.tel">
                    <span class="tel_error" v-show="error_tel">固定电话有误</span>
                </div>
                <div class="form_group">
                    <label>邮箱：</label>
                    <input @blur="check_email" class="email" type="text" v-model="form_address.email">
                    <span class="email_error" v-show="error_email">邮箱信息有误</span>
                </div>
                <input @click="save_address" class="info_submit" name="" value="新 增">
                <input @click="is_show_edit=false" class="info_submit info_reset" name="" type="reset" value="取 消">
            </form>
        </div>
        <div class="mask"></div>
    </div>
</div>
<script type="text/javascript">
    let addresses = {{ addresses | safe }};
    let default_address_id = {{ default_address_id }};
</script>
<script src="{% static 'js/common.js' %}" type="text/javascript"></script>
<script src="{% static 'js/user_center_site.js' %}" type="text/javascript"></script>
</body>
</html>